﻿<%@ Page Title="" Language="C#" MasterPageFile="~/masterpage_user.master" AutoEventWireup="true"
    CodeFile="editQLSanPham.aspx.cs" Inherits="editQLSanPham" %>

<asp:Content ID="Content1" ContentPlaceHolderID="user_content" runat="Server">
    <script src="./javascripts/t_js.js"></script>
    <div id="quanlysanpham">
    <div class="title">
        Quản Lý Sản Phẩm</div>

    <div class="featureUpload">
    
    <div class="upload1">
        <ajaxToolkit:AsyncFileUpload ID="AsyncFileUpload1" runat="server" OnClientUploadError="uploadError"
        OnClientUploadStarted="StartUpload" 
        OnClientUploadComplete="UploadComplete" CompleteBackColor="Lime"
        ErrorBackColor="Red" ThrobberID="Throbber" OnUploadedComplete="AsyncFileUpload1_UploadedComplete"
        UploadingBackColor="#66CCFF" Visible="False" /></div>
   
    <div class="upload2">
         <asp:Label ID="Label7" runat="server" Text="Tải ảnh lên:" Font-Bold="True" 
            Font-Names="Arial" ForeColor="#507CD1" Visible="False"></asp:Label>&nbsp;
    </div>
    </div>

    <div class="messageReport">
        <asp:Label ID="Throbber" runat="server" Style="display: none" ClientIDMode="Static">
        <img src="Images/indicator.gif" alt="loading" />
        </asp:Label>
        <asp:Label ID="lblStatus" runat="server" Font-Names="Arial" ForeColor="#507CD1"
            ClientIDMode="Static"></asp:Label>
    </div>
    <br />
    <%--ClientIDMode="Static" để javascript ở client có thể nhận ra--%>

    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
        DataKeyNames="Masanpham" DataSourceID="SqlDataSource1" Font-Names="Arial" 
            Height="50px" HorizontalAlign="Center" Width="700px" 
            OnPageIndexChanging="DetailsView1_PageIndexChanging" CssClass="table-a">
        <AlternatingRowStyle CssClass="table-a"/>
        <FieldHeaderStyle HorizontalAlign="Left"
            VerticalAlign="Middle" />
        <Fields>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:Button ID="btCapNhat" runat="server" CausesValidation="True" CommandName="Update"
                        Text="Cập nhật" OnClick="btTurnOffUpload_Click" />
                    &nbsp;<asp:Button ID="btHuy" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Hủy" OnClick="btTurnOffUpload_Click" />
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:Button ID="Button1" runat="server" CausesValidation="True" CommandName="Insert"
                        Text="Thêm" OnClick="btTurnOffUpload_Click" />
                    &nbsp;<asp:Button ID="Button2" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Hủy" OnClick="btTurnOffUpload_Click" />
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Button ID="Button1" runat="server" CausesValidation="False" CommandName="Edit"
                        Text="Sửa" OnClick="btTurnOnUpload_Click" />
                    &nbsp;<asp:Button ID="Button2" runat="server" CausesValidation="False" CommandName="New"
                        Text="Thêm" OnClick="btTurnOnUpload_Click" />
                    &nbsp;<asp:Button ID="btQuayLai" runat="server" OnClick="btQuayLai_Click" Text="Quay lại" />
                </ItemTemplate>
                <ItemStyle BackColor="#99CCFF" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Mã Sản Phẩm" SortExpression="Masanpham">
                <EditItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("Masanpham") %>' Font-Names="Arial"
                        ForeColor="White"></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Masanpham") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle Font-Bold="False" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Mã Shop" SortExpression="Mashop">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
                        DataTextField="Masanpham" DataValueField="Mashop" 
                        SelectedValue='<%# Bind("Mashop") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:DropDownList ID="dlMaShop" runat="server" DataSourceID="SqlDataSource2" DataTextField="Tenshop"
                        DataValueField="Mashop" SelectedValue='<%# Bind("mashop") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Mashop") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Tên Sản Phẩm" SortExpression="Tensanpham">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Tensanpham") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="txtTenSP" runat="server" Text='<%# Bind("tensp") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("Tensanpham") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Loại Sản Phẩm" SortExpression="loaisanpham">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource3"
                        DataTextField="Tenloai" DataValueField="Maloaisanpham" 
                        SelectedValue='<%# Bind("loaisanpham") %>' AppendDataBoundItems="True">
                    <asp:ListItem Text="Chọn lựa..." Value=""></asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:DropDownList ID="dlLoaiSP" runat="server" DataSourceID="SqlDataSource3" DataTextField="Tenloai"
                        DataValueField="Maloaisanpham" SelectedValue='<%# Bind("loaisp") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("loaisanpham") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="URL" SortExpression="URL">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("URL") %>' Width="477px"
                        ClientIDMode="Static"></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox4" runat="server" Width="477px" Text='<%# Bind("url") %>' ClientIDMode="Static"></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("URL") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Giá" SortExpression="giasanpham">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("giasanpham") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="txtGia" runat="server" Text='<%# Bind("giasp") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("giasanpham") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Mô Tả" SortExpression="Mota">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("Mota") %>' Height="269px"
                        TextMode="MultiLine" Width="477px"></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="txtMoTa" runat="server" Height="269px" TextMode="MultiLine" Width="477px"
                        Text='<%# Bind("mota") %>' Font-Names="Rod" Font-Size="Small"></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:TextBox ID="TextBox7" runat="server" Font-Names="Arial" Font-Size="Medium" ForeColor="#507CD1"
                        Height="269px" ReadOnly="True" Text='<%# Bind("Mota") %>' TextMode="MultiLine"
                        Width="477px"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
        </Fields>
        <HeaderStyle HorizontalAlign="Center"
            VerticalAlign="Middle" />
    </asp:DetailsView>
    </div>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:chodientuConnectionString %>"
        DeleteCommand="DELETE FROM [Sanpham] WHERE [Masanpham] = @Masanpham" InsertCommand="sp_ThemSanPham"
        SelectCommand="SELECT * FROM [Sanpham] WHERE ([Masanpham] = @Masanpham)" UpdateCommand="UPDATE [Sanpham] SET [Mashop] = @Mashop, [Tensanpham] = @Tensanpham, [loaisanpham] = @loaisanpham, [URL] = @URL, [giasanpham] = @giasanpham, [Mota] = @Mota WHERE [Masanpham] = @Masanpham"
        InsertCommandType="StoredProcedure">
        <DeleteParameters>
            <asp:Parameter Name="Masanpham" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="mashop" Type="String" />
            <asp:Parameter Name="tensp" Type="String" />
            <asp:Parameter Name="loaisp" Type="String" />
            <asp:Parameter Name="url" Type="String" />
            <asp:Parameter Name="giasp" Type="Double" />
            <asp:Parameter Name="mota" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="TextBox1" ConvertEmptyStringToNull="False" Name="Masanpham"
                PropertyName="Text" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Mashop" />
            <asp:Parameter Name="Tensanpham" />
            <asp:Parameter Name="loaisanpham" />
            <asp:Parameter Name="URL" />
            <asp:Parameter Name="giasanpham" />
            <asp:Parameter Name="Mota" />
            <asp:Parameter Name="Masanpham" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:chodientuConnectionString %>"
        SelectCommand="SELECT * FROM [Shop] WHERE ([Username] = @Username)">
        <SelectParameters>
            <asp:SessionParameter Name="Username" SessionField="User" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:chodientuConnectionString %>"
        SelectCommand="SELECT * FROM [Loaisanpham]"></asp:SqlDataSource>
    <asp:TextBox ID="TextBox1" runat="server" Visible="False"></asp:TextBox>
</asp:Content>
